<template>
      <div class="personCard">
      <div class="personCard-top">
        <!-- 头像 -->
        <div class="personCard-top-avatar-pr" style="margin-left: 10px;">
          <el-avatar :size="56" :src="this.$store.state.user.avatar" style="cursor: pointer;position: relative;right: 8px;" class="avatar"></el-avatar>
        </div>
        <!-- 头像右侧 -->
        <div class="personCard-top-right">
          <!-- nickname -->
          <div class="name-boxtop">
            <a href="">{{$store.state.user.account}}</a>
          </div>
          <div class="name-boxbottom">
              <p style="font-size: small;margin: 0;opacity: 0.7;">码龄1年</p>
          </div>     
        </div>
      </div>

     <div class="personCard-items">
        <!-- 原创 -->
        <div class="personCard-item">
          <span> {{count}} </span>
          <br>
          <a href="">原创</a>
        </div>
        <!--周排名 -->
        <div class="personCard-item">
        <span> - </span>
        <br>
        <a href="">周排名</a>
        </div>

        <!--总排名 -->
        <div class="personCard-item">
        <span> - </span>
        <br>
        <a href="">总排名</a>
        </div>
        <!--访问 -->
        <div class="personCard-item">
        <span> - </span>
        <p>访问</p>
        </div>

     </div>

     <div class="personCard-items">
        <!-- 粉丝 -->
        <div class="personCard-item">
          <span> - </span>
          <p>粉丝</p>
        </div>
        <!--获赞 -->
        <div class="personCard-item">
        <span> - </span>
        <p>获赞</p>
        </div>

        <!--评论 -->
        <div class="personCard-item">
        <span> - </span>
        <p>评论</p>
        </div>
        <!--收藏 -->
        <div class="personCard-item">
        <span> - </span>
        <p>收藏</p>
        </div>

     </div>

     <div class="personCard-btn" v-show="isMe">
      <el-button round>私信</el-button>
      <el-button round @click="follow">{{$store.state.isfollow}}</el-button>

     </div>



    </div>
</template>

<script>


import {countUserReleaseArticle} from "@/api/article";
import {getFollow, toFollow} from "@/api/user";

export default {
     name:"PersonCard",
  data(){
       return{
       user:{
         articleCount:"",
       },

       }
  },
  methods:{
    follow(){
      toFollow(this.$store.state.article.userId).then(res=>{
        this.$store.commit("FOLLOW",res);
      })
    },
  },
  computed:{
    isMe(){
        return this.$store.state.user.account !== localStorage.getItem("nickname");
    },
    count(){
      //TODO
      const userId=this.$store.state.user.userId;
      countUserReleaseArticle(userId).then(res=>{
              this.user.articleCount=res;
      })
      return this.user.articleCount;
    }
  },


}
</script>

<style>
a{
  color: black;
  text-decoration: none;
}
a:hover{
  color: red;
}
.personCard{
  width: 300px;
  height: 300px;
  background-color:white;
  padding: 20px ;
  
}
.personCard .personCard-top{
  display: flex;
  width: 260px;
  height: 48px;
  /* background-color: blue; */

}
.personCard-top-avatar-pr{
   flex-basis: 48px;
   /* background-color: lawngreen; */
}
.personCard-top-right{
  flex-basis: 212px;
  /* border-color: rgb(33, 164, 26); */
  display: flex;
  flex-direction: column;
  margin-left: 10px;
}
.name-boxtop,.name-boxbottom{
  flex-grow:1;

}
.personCard-items{
  width: 100%;
  height: 70px;
  /* background-color: aqua; */
  margin-top: 18px;
  display: flex;
  justify-content: space-around;
  text-align: center;
}
.personCard-items p{
  margin-top: 10px;
  opacity: 0.5;
  font-size: 14px;
}
.personCard-items a{
  display: block;
  margin-top: 10px;
  font-size: 14px;
}
.personCard-item span{
  opacity: 0.7;
  font-size: 14px;
}
.personCard-btn{
  margin-top: 20px;
  width: 100%;
  height: 30px;
  display: flex;
  justify-content: space-around;

}
.personCard-btn button{
  line-height: 5px;
  flex-basis: 120px ;
  border: 1px solid rgb(0, 0, 0,0.5);
}

</style>